import Request from 'axios'
import NProgress from 'nprogress'
import store from '../store/index'
import { getCookie } from '../plugins/tools'
NProgress.configure({
  showSpinner: false
})
const Axios = Request.create({
  baseURL: '', // 走本地代理不需要配置
  timeout: 600000
})
Axios.interceptors.request.use((config) => {
  NProgress.start()
  if (config.meta.auth) {
    config.headers.Authorization = store.getters.token || getCookie('Access-Token')
  }
  return config
})
Axios.interceptors.response.use((response) => {
  NProgress.done()
  return response
})
export default Axios
